package com.gxa.controller.zhy;

import com.gxa.common.R;
import com.gxa.pojo.*;
import com.gxa.pojo.zhy.AdminInformation;
import com.gxa.pojo.zhy.Pr;
import io.swagger.annotations.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: 赵贺益
 * Date: 2021/12/02 17:23
 * Description:
 * Version: V1.0
 */
@Controller
@Api(value ="" ,tags = "系统管理模块接口")
@RequestMapping("/system")
public class SystemManagementController {

    /**
     * 获取系统信息，并显示到表单中
     * @return
     */
    @ResponseBody
    @RequestMapping(value ="/querySystemConfig",method = RequestMethod.GET)
    @ApiOperation(value = "获取系统设置信息的接口",notes = "返回的是一个对象R",httpMethod = "GET", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message = "查询成功"),
            @ApiResponse(code=504,message = "查询失败"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R querySystemConfig(){
        R r=new R();
        System_Config_Param system_config_param=new System_Config_Param();
        system_config_param.setSystem_name("爱之情人事系统V4商业版");
        system_config_param.setUrl_address("https://www.huzhan.com");
        system_config_param.setFirm_name("爱之情信息科技");
        system_config_param.setFirm_introduce("爱之情信息科技承接APP，小程序，直销系统，资金盘系统，电商系统的开发");
        system_config_param.setTelephone("15887835880");
        system_config_param.setVerification_code(0);
        system_config_param.setLogin_timeout(100);
        system_config_param.setLogin_falsecount(100);
        system_config_param.setLogo("bchisdbcjdkvhj");
        r.setCode(200);
        r.setMsg("查询成功");
        r.setData(system_config_param);
        return  r;
    }

    /**
     * 修改系统设置的接口
     * @param system_config_param
     * @param request
     * @return
     */

    @ResponseBody
    @RequestMapping(value ="/updateSystemConfig",method = RequestMethod.POST)
    @ApiOperation(value = "修改系统设置信息的接口",notes = "返回的是一个对象R.",httpMethod = "POST", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message = "修改成功"),
            @ApiResponse(code=504,message = "修改失败"),
            @ApiResponse(code=501,message = "没有选中图片"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public  R updateSystemConfig(@RequestBody @ApiParam System_Config_Param system_config_param, HttpServletRequest request){
          R  r=new R();
          r.setCode(200);
          r.setMsg("修改成功");
          return  r;
    }

    /**
     * 查询所有的配置变量相关信息的接口，用于显示到表中
     * @return
     */

    @ResponseBody
    @RequestMapping(value ="/queryAllConfig",method = RequestMethod.GET)
    @ApiOperation(value = "查询所有的配置变量相关信息的接口",notes = "返回的是一个R对象，R对象中的data中装了一个对象List<Params>(集合对象)用于显示到表中，对象结构如下",httpMethod = "GET", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message = "查询成功"),
            @ApiResponse(code=504,message = "查询失败"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })

    public R  queryAllConfigParams(){
        R r=new R();
        Params params1=new Params();
        Params params2=new Params();
        Params params3=new Params();
        params1.setParam_id(1);
        params1.setParam_name("education");
        params1.setParam_remark("学历字段");
        params1.setParam_num(1);

        params2.setParam_id(2);
        params2.setParam_name("titles");
        params2.setParam_remark("职称字段");
        params2.setParam_num(2);

        params3.setParam_id(3);
        params3.setParam_name("position");
        params3.setParam_remark("职务字段");
        params3.setParam_num(3);
        List<Params> paramsList=new ArrayList<>();
        paramsList.add(params1);
        paramsList.add(params2);
        paramsList.add(params3);
        r.setCode(200);
        r.setMsg("查询成功");
        r.setData(paramsList);
        return r;

    }

    /**
     * 查询配置变量值的接口（用于下拉框显示）
     * @param param_id
     * @return
     */


    @ResponseBody
    @RequestMapping(value ="/queryParam_value",method = RequestMethod.GET)
    @ApiOperation(value = "查询配置变量值的接口",notes = "返回的是一个R对象，R对象中的data中装了一个List(集合对象)（用于下拉框显示），对象结构如下",httpMethod = "GET", response =R.class)
    @ApiImplicitParam(name = "param_id",value = "选中行配置变量的ID",required =true,paramType ="query")
//    public  List<Params_Son> queryParam_value(Integer param_id){
    @ApiResponses({
            @ApiResponse(code=200,message = "查询成功"),
            @ApiResponse(code=504,message = "查询失败"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R queryParam_value(Integer param_id){
        R r=new R();
        Params_Son params_son1=new Params_Son();
        Params_Son params_son2=new Params_Son();
        Params_Son params_son3=new Params_Son();
        Params_Son params_son4=new Params_Son();
        Params_Son params_son5=new Params_Son();
        Params_Son params_son6=new Params_Son();
//        初中以下|初中|高中/中专|大专|本科|硕士|博士|博士后|院士
        params_son1.setParam_value("初中以下");
        params_son2.setParam_value("初中");
        params_son3.setParam_value("高中/中专");
        params_son4.setParam_value("大专");
        params_son5.setParam_value("本科");
        params_son6.setParam_value("硕士");
        List<Params_Son> params_sonList=new ArrayList<>();
        params_sonList.add(params_son1);
        params_sonList.add(params_son2);
        params_sonList.add(params_son3);
        params_sonList.add(params_son4);
        params_sonList.add(params_son5);
        params_sonList.add(params_son6);
        r.setData(params_sonList);
        return r;
    }

    /**
     * 添加配置变量值的接口
     * @param param_value
     * @return
     */
    @ResponseBody
    @RequestMapping(value ="/addParam_value",method = RequestMethod.POST)
    @ApiOperation(value = "添加配置变量值的接口",notes = "返回的是一个R对象,结构如下",httpMethod = "POST", response =R.class)
    @ApiImplicitParam(name = "param_value",value = "输入框中新增的配置变量的值",required =true,paramType ="query")
    @ApiResponses({
            @ApiResponse(code=200,message = "添加成功"),
            @ApiResponse(code=300,message = "该变量值已经存在"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R addParam_value(String param_value){
       R r=new R();
       r.setCode(200);
       r.setMsg("添加成功");
       return r;
    }

    /**
     * 下拉框中选中的配置变量值进行删除
     * @param param_value
     * @return
     */

    @ResponseBody
    @RequestMapping(value ="/deleteParam_value",method = RequestMethod.GET)
    @ApiOperation(value = "删除配置变量值的接口",notes = "返回的是一个R对象,结构如下",httpMethod = "GET", response =R.class)
    @ApiImplicitParam(name = "param_value",value = "下拉框中选中的配置变量的值",required =true,paramType ="query")
    @ApiResponses({
            @ApiResponse(code=200,message = "删除成功"),
            @ApiResponse(code=504,message = "删除失败"),
            @ApiResponse(code = 500,message = "后台服务错误")

    })
    public  R deleteParam_value(String param_value){
        R r=new R();
        r.setCode(200);
        r.setMsg("删除成功");
        return r;
    }


    /**
     * 根据当前页码数和每页显示的数量查询所有的角色以及相关信息
     * @param currentPage
     * @param pageSize
     * @return
     */

    @ResponseBody
    @RequestMapping(value ="/queryAllRoles",method = RequestMethod.GET)
    @ApiOperation(value = "请求获取所有角色的接口（默认currentPage=1（当前页码），pageSize=10（每页显示的数据））",notes = "返回的是一个对象List<Role>(集合对象)，对象结构如下",httpMethod = "GET", response =Role.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前的页码数" ,required = false,paramType = "query"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示的条数",required =false,paramType ="query")

    })

    @ApiResponses({
            @ApiResponse(code=200,message = "查询成功"),
            @ApiResponse(code=504,message = "查询失败"),
            @ApiResponse(code = 500,message = "后台服务错误")

    })
    public List<Role> queryAllRoles(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage,@RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
       Role role1=new Role();
       Role role2=new Role();
       Role role3=new Role();
       Role role4=new Role();

       role1.setRole_id(1);
       role1.setRole_name("部门管理角色");
       role1.setRole_describe("管理部门");
        /**
         * 为什么塞这个
         */
       role1.setPermission_id(1);

        role2.setRole_id(2);
        role2.setRole_name("部门相关角色");
        role2.setRole_describe("相关部门");
        role2.setPermission_id(2);

        role3.setRole_id(3);
        role3.setRole_name("员工管理角色");
        role3.setRole_describe("管理员工");
        role3.setPermission_id(3);

        role4.setRole_id(4);
        role4.setRole_name("管理员管理角色");
        role4.setRole_describe("管理管理员");
        role4.setPermission_id(4);
        List<Role> roleList=new ArrayList<>();
        roleList.add(role1);
        roleList.add(role2);
        roleList.add(role3);
        roleList.add(role4);

        return roleList;

    }


    /**
     * 模糊搜索显示所有的角色
     * @param currentPage
     * @param pageSize
     * @param keyword
     * @return
     */
    @ResponseBody
    @RequestMapping(value ="/querySearchRolesbyKeyword",method = RequestMethod.GET)
    @ApiOperation(value = "请求获取所有角色的接口（默认currentPage=1（当前页码），pageSize=10（每页显示的数据））",notes = "返回的是一个对象List<Role>(集合对象)，对象结构如下",httpMethod = "GET", response =Role.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前的页码数" ,required = false,paramType = "query"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示的条数",required =false,paramType ="query"),
            @ApiImplicitParam(name = "keyword",value = "搜索框输入的关键字",required =false,paramType ="query")
    })

    public List<Role> querySearchRolesbyKeyword(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage,@RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,String keyword){
        Role role1=new Role();
        Role role2=new Role();
        Role role3=new Role();
        Role role4=new Role();

        role1.setRole_id(1);
        role1.setRole_name("部门管理角色");
        role1.setRole_describe("管理部门");
        role1.setPermission_id(1);

        role2.setRole_id(2);
        role2.setRole_name("部门相关角色");
        role2.setRole_describe("相关部门");
        role2.setPermission_id(2);

        role3.setRole_id(3);
        role3.setRole_name("员工管理角色");
        role3.setRole_describe("管理员工");
        role3.setPermission_id(3);

        role4.setRole_id(4);
        role4.setRole_name("管理员管理角色");
        role4.setRole_describe("管理管理员");
        role4.setPermission_id(4);
        List<Role> roleList=new ArrayList<>();
        roleList.add(role1);
        roleList.add(role2);
        roleList.add(role3);
        roleList.add(role4);

        return roleList;

    }


    /**
     * 根据角色id(role_id)删除角色
     * @param role_id
     * @return
     */

    @ResponseBody
    @RequestMapping(value ="/deleteRoleByRole_id",method = RequestMethod.GET)
    @ApiOperation(value = "删除指定角色的接口",notes = "返回的是一个对象R，对象结构如下",httpMethod = "GET", response =R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "role_id",value = "当前行数据的id（role_id）" ,required = true,paramType = "query")
               })

    @ApiResponses({
            @ApiResponse(code=200,message = "删除成功"),
            @ApiResponse(code=504,message = "删除失败"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })

    public R deleteRoleByRole_id(Integer role_id ){
        R r=new R();
        r.setCode(200);
        r.setMsg("删除成功");
        return  r;
    }


    /**
     * 添加角色
     * @param role_name
     * @param role_describe
     * @return
     */

    @ResponseBody
    @RequestMapping(value ="/addRole",method = RequestMethod.POST)
    @ApiOperation(value = "添加角色的接口",notes = "返回的是一个对象R，对象结构如下",httpMethod = "POST", response =R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "role_name",value = "角色名称" ,required = true,paramType = "query"),
            @ApiImplicitParam(name = "role_describe",value = "角色描述" ,required = true,paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "添加成功"),
            @ApiResponse(code=504,message = "添加失败"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public  R addRole(String role_name,String role_describe){
        R r=new R();
        r.setCode(200);
        r.setMsg("添加成功");
        return r;
    }


    /**
     * 根据角色id请求显示其对应的所有的权限
     * @param role_id
     * @return
     */
    @ResponseBody
    @RequestMapping(value ="/queryAllRolesByRole_id",method = RequestMethod.GET)
    @ApiOperation(value = "返回对应角色接口",notes = "返回的是一个对象R，对象结构如下",httpMethod = "POST", response =R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "role_id",value = "角色id" ,required = true,paramType = "query"),
               })
    @ApiResponses({
            @ApiResponse(code=200,message = "查询成功"),
            @ApiResponse(code=504,message = "查询失败"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R queryAllRolesByRole_id(Integer role_id){
        R r=new R();
        List<Performance> list1 = new ArrayList<Performance>();//二级菜单list
        list1.add(new Performance());
        list1.add(new Performance());
        list1.add(new Performance());

        Pr pr=new Pr("系统管理",list1);
        Pr pr2=new Pr("部门管理",list1);
        Pr pr3=new Pr("员工管理",list1);
        List<Pr> list2 = new ArrayList<Pr>();
        list2.add(pr);
        list2.add(pr2);
        list2.add(pr3);
        r.setCode(200);
        r.setMsg("查询成功");
        r.setData(list2);
        return  r;
    }

    /**
     * 查询获取所有的角色，用于下拉框显示
     * @param
     * @param
     * @return
     */

    @ResponseBody
    @RequestMapping(value ="/queryAllRolesInsert",method = RequestMethod.GET)
    @ApiOperation(value = "请求获取所有的角色",notes = "返回的是一个R，R对象中的data中存了一个对象List<Role>(集合对象)，对象结构如下",httpMethod = "GET", response =R.class)
    @ApiResponses({
            @ApiResponse(code=200,message = "查询成功"),
            @ApiResponse(code=504,message = "查询失败"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
//    public List<Role> queryAllRoles(){
    public R queryAllRoles(){
        R r=new R();

        Role role1=new Role();
        Role role2=new Role();
        Role role3=new Role();
        Role role4=new Role();


        role1.setRole_id(1);
        role1.setRole_name("部门管理角色");
        role1.setRole_describe("管理部门");
        role1.setPermission_id(1);

        role2.setRole_id(2);
        role2.setRole_name("部门相关角色");
        role2.setRole_describe("相关部门");
        role2.setPermission_id(2);

        role3.setRole_id(3);
        role3.setRole_name("员工管理角色");
        role3.setRole_describe("管理员工");
        role3.setPermission_id(3);

        role4.setRole_id(4);
        role4.setRole_name("管理员管理角色");
        role4.setRole_describe("管理管理员");
        role4.setPermission_id(4);
        List<Role> roleList=new ArrayList<>();
        roleList.add(role1);
        roleList.add(role2);
        roleList.add(role3);
        roleList.add(role4);
        r.setCode(200);
        r.setMsg("查询成功");
        r.setData(roleList);
        return r;

    }


    /**
     * 添加管理员
     * @param username
     * @param user_password
     * @param emp_number
     * @param role_id
     * @return
     */
    @ResponseBody
    @RequestMapping(value ="/addUsers",method = RequestMethod.GET)
    @ApiOperation(value = "返回对应角色接口",notes = "返回的是一个对象R，对象结构如下",httpMethod = "POST", response =R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username",value = "登录账号" ,required = true,paramType = "query"),
            @ApiImplicitParam(name = "user_password",value = "登录密码" ,required = true,paramType = "query"),
            @ApiImplicitParam(name = "role_id",value = "角色id，根据上面下拉返回对应的角色id" ,required = true,paramType = "query"),
            @ApiImplicitParam(name = "emp_number",value = "员工编号（手动输入，判断该管理员是否已经是员工，是员工才可成为管理员）" ,required = true,paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "添加管理员成功"),
            @ApiResponse(code=504,message = "添加失败"),
            @ApiResponse(code=503,message = "该员工编号不存在，要先成为员工才能成为管理员"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })

    public  R addUsers(String username,String user_password,String emp_number, Integer role_id){

        R r=new R();
        r.setCode(200);
        r.setMsg("添加管理员成功");
        return  r;

    }



    /**
     * 返回所有的用户（管理员）信息
     * @param currentPage
     * @param pageSize
     * @return
     */
    @ResponseBody
    @RequestMapping(value ="/queryAllUsers",method = RequestMethod.GET)
    @ApiOperation(value = "返回所有的用户（管理员）信息的接口(（默认currentPage=1（当前页码），pageSize=10（每页显示的数据））)",notes = "返回的是一个对象List<Users>对象，对象结构如下",httpMethod = "POST", response =Users.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数" ,required = true,paramType = "query"),
            @ApiImplicitParam(name = "pageSize",value = "当前页面显示的数据条数" ,required = true,paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "请求成功"),
            @ApiResponse(code=504,message = "请求失败"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
//    public List<AdminInformation> queryAllUsers(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage,@RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
    public R queryAllUsers(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage,@RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
        R r=new R();
      AdminInformation adminInformation1=new AdminInformation();
      AdminInformation adminInformation2=new AdminInformation();
        adminInformation1.setUser_id(1);
        adminInformation1.setUsername("123456");
        adminInformation1.setEmp_name("谢志浩");
        adminInformation1.setEmp_sex("男");
        adminInformation1.setEmp_tel("1234567");
        adminInformation1.setRole_name("超级管理员");
        adminInformation1.setStatue(1);

        adminInformation2.setUser_id(2);
        adminInformation2.setUsername("1236");
        adminInformation2.setEmp_name("志浩");
        adminInformation2.setEmp_sex("女");
        adminInformation2.setEmp_tel("12367");
        adminInformation2.setRole_name("超级管理员");
        adminInformation1.setStatue(0);
        List list=new ArrayList();
        list.add(adminInformation1);
        list.add(adminInformation2);
        r.setCode(200);
        r.setMsg("查询成功");
        r.setData(list);
        return r;

    }

    /**
     * 根据管理员的id（user_id）删除管理员
     * @param user_id
     * @return
     */
    @ResponseBody
    @RequestMapping(value ="/delUserbyuser_id",method = RequestMethod.GET)
    @ApiOperation(value = "删除（管理员）信息的接口",notes = "返回的是一个R对象，对象结构如下",httpMethod = "GET", response =R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "user_id",value = "当前行的管理员的id'" ,required = true,paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "删除成功"),
            @ApiResponse(code=504,message = "删除失败失败"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R delUserbyuser_id(Integer user_id){
       R r=new R();
       r.setCode(200);
       r.setMsg("删除成功");
       return r;

    }




    @ResponseBody
    @RequestMapping(value ="/queryAdminInformationByinformation",method = RequestMethod.GET)
    @ApiOperation(value = "关键字模糊搜索（管理员）信息的接口",notes = "返回的是一个R对象，对象结构如下,R的data中存了一个List（AdminInformation）对象，也就是List中装了很多对象",httpMethod = "GET", response =R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "information",value = "搜索框中输入的信息'" ,required = true,paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "查询成功"),
            @ApiResponse(code=504,message = "查询失败"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public  R queryAdminInformationByinformation(String  information){
        R r=new R();
        AdminInformation adminInformation1=new AdminInformation();
        AdminInformation adminInformation2=new AdminInformation();
        adminInformation1.setUser_id(1);
        adminInformation1.setUsername("12345678");
        adminInformation1.setEmp_name("谢志浩");
        adminInformation1.setEmp_sex("男");
        adminInformation1.setEmp_tel("3456789");
        adminInformation1.setRole_name("超级管理员");
        adminInformation1.setStatue(1);

        adminInformation2.setUser_id(2);
        adminInformation2.setUsername("1236");
        adminInformation2.setEmp_name("志浩");
        adminInformation2.setEmp_sex("女");
        adminInformation2.setEmp_tel("12367");
        adminInformation2.setRole_name("超级管理员");
        adminInformation1.setStatue(0);
        List list=new ArrayList();
        list.add(adminInformation1);
        list.add(adminInformation2);
        r.setCode(200);
        r.setMsg("查询成功");
        r.setData(list);
        return  r;
    }

    /**
     * 修改管理员的状态
     * @param user_id
     * @return
     */
    @ResponseBody
    @RequestMapping(value ="/updateUserStatue",method = RequestMethod.GET)
    @ApiOperation(value = "修改（管理员）状态信息的接口",notes = "返回的是一个R对象，对象结构如下",httpMethod = "GET", response =R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "user_id",value = "当前行的管理员的id'" ,required = true,paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "修改状态成功"),
            @ApiResponse(code=504,message = "修改状态失败"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R updateUserStatue(Integer user_id){
        R r=new R();
        r.setCode(200);
        r.setMsg("修改状态成功");
        return  r;

    }



    /**
     * 对管理员信息进行修改操作
     * @return
     */

    @ResponseBody
    @RequestMapping(value ="/updateUsersInformation",method = RequestMethod.POST)
    @ApiOperation(value = "修改用户（管理员）信息的接口",notes = "返回的是R对象，对象结构如下",httpMethod = "POST", response =R.class)

    @ApiResponses({
            @ApiResponse(code=200,message = "修改成功"),
            @ApiResponse(code=504,message = "修改失败"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public  R updateUsersInformation( @RequestBody @ApiParam AdminInformation adminInformation){
      R r=new R();
      r.setCode(200);
      r.setMsg("修改成功");
      return  r;

    }






}
